import 'package:flutter/material.dart';
import 'package:ljy_flutter/provider/provider_counter.dart';
import 'package:provider/provider.dart';

class ProviderNextPage extends StatelessWidget {
  const ProviderNextPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('provider next page demo')),
      body: Consumer<ProviderName>(
        builder: (context, pn, child) {
          return Center(
            child: Column(
              children: [
                Text(pn.name),
                OutlinedButton(
                  onPressed: () {
                    pn.changeName();
                  },
                  child: Text('改变名称'),
                ),
                OutlinedButton(
                  onPressed: () {
                    pn.increment();
                  },
                  child: Text('增加计数'),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
